Using DBE and callbacks: null Module do loop parameter was passed

Hello,

I am running the following script and I get the error " null Module do loop parameter was passed " when I press the button "Element".

The paramter entered tells the script the name of the attribute to copy text from

Currently I can only make it run hard coded, which is very limiting. Any one can see what is wrong?
regards

Colm

//BEGIN script.
DB modNameDB = create("Enter Module Source name", styleStandard)
DBE mName = field(modNameDB,"Module:", "theModName",20,false);
Module m = current

void buttonCallback(DBE element)
{
print "button callback"
string theColName= get(mName)
print theColName "\n"
string fullname = "DXL for Out-links (" theColName ")"
print "button callback"
Object o
string src=""
for o in m do
{
src= o.fullname
o."Object Text" = src
}
}

void standardCallback(DB win)
{
print "standard callback"
hide (win)

}

DBE buttonDBE = button(modNameDB ,"Element",buttonCallback)
apply(modNameDB,"Bar",standardCallback)
close(modNameDB,true,standardCallback)
show(modNameDB)
MyDeveloerWorks - Wed Nov 28 08:14:37 EST 2012

Re: Using DBE and callbacks: null Module do loop parameter was passed
Peter_Albert - Wed Nov 28 08:29:28 EST 2012

Well, the error message tells you, that the Module ('m') in your case, is null. 'm' is set to the current Module. If the current Module is null, this means that you most likely ran the script from the database explorer window. Try running it from a Module window, and it should work.

BTW, a check like

if (null current Module){halt}

is always a good idea if a script relies on the current Module

Cheers,

Peter

Re: Using DBE and callbacks: null Module do loop parameter was passed
MyDeveloerWorks - Wed Nov 28 09:04:37 EST 2012

Peter_Albert - Wed Nov 28 08:29:28 EST 2012

Well, the error message tells you, that the Module ('m') in your case, is null. 'm' is set to the current Module. If the current Module is null, this means that you most likely ran the script from the database explorer window. Try running it from a Module window, and it should work.

BTW, a check like

if (null current Module){halt}

is always a good idea if a script relies on the current Module

Cheers,

Peter

I added the script o the user menu, copying out theUser function Mneu item and I run the script from the module I want to have as current.. Why cant it recognise it as current?

BTW, thanks for the halt trick.

Re: Using DBE and callbacks: null Module do loop parameter was passed
llandale - Wed Nov 28 11:33:17 EST 2012

MyDeveloerWorks - Wed Nov 28 09:04:37 EST 2012
I added the script o the user menu, copying out theUser function Mneu item and I run the script from the module I want to have as current.. Why cant it recognise it as current?

BTW, thanks for the halt trick.

Don't understand:
  • copying out theUser function Mneu item

Otherwise "m" should end up correctly set to the current module.

On other news:
  • src= o.fullname
This implies "fullname" is the name of an attribute but it appears to me it is actually the contents of some column layout. If so you need to convert the column title to a Column handle and then get the text of that object.
  • Column col
  • for col in m do
  • { if (title(col) == fullName)
    • src = getText(col, o)
    • etc
  • }
-Louie